<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: ProductResource</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: ProductResource</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>ProductResource<span class="signature">()</span><span class="type-signature"></span></h2>
        
            <div class="class-description"><p>The JS Buy SDK product resource</p></div>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    
    <h2>Constructor</h2>
    

    
    <h4 class="name" id="ProductResource"><span class="type-signature"></span>new ProductResource<span class="signature">()</span><span class="type-signature"></span></h4>
    

    















<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>




















    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="fetch"><span class="type-signature"></span>fetch<span class="signature">(id)</span><span class="type-signature"> &rarr; {Promise|GraphModel}</span></h4>
    

    



<div class="description">
    <p>Fetches a single product by ID on the shop.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>id</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>The id of the product to fetch.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line51">line 51</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A promise resolving with a <code>GraphModel</code> of the product.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>
|

<span class="param-type">GraphModel</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>client.product.fetch('Xk9lM2JkNzFmNzIQ4NTIY4ZDFi9DaGVja291dC9lM2JkN==').then((product) => {
  // Do something with the product
});</code></pre>



        
            

    

    
    <h4 class="name" id="fetchAll"><span class="type-signature"></span>fetchAll<span class="signature">(pageSize<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise|Array.&lt;GraphModel>}</span></h4>
    

    



<div class="description">
    <p>Fetches all products on the shop.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>pageSize</code></td>
            

            <td class="type">
            
                
<span class="param-type">Int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The number of products to fetch per page</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line33">line 33</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A promise resolving with an array of <code>GraphModel</code>s of the products.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>
|

<span class="param-type">Array.&lt;GraphModel></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>client.product.fetchAll().then((products) => {
  // Do something with the products
});</code></pre>



        
            

    

    
    <h4 class="name" id="fetchByHandle"><span class="type-signature"></span>fetchByHandle<span class="signature">(handle)</span><span class="type-signature"> &rarr; {Promise|GraphModel}</span></h4>
    

    



<div class="description">
    <p>Fetches a single product by handle on the shop.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>handle</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>The handle of the product to fetch.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line88">line 88</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A promise resolving with a <code>GraphModel</code> of the product.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>
|

<span class="param-type">GraphModel</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>client.product.fetchByHandle('my-product').then((product) => {
  // Do something with the product
});</code></pre>



        
            

    

    
    <h4 class="name" id="fetchMultiple"><span class="type-signature"></span>fetchMultiple<span class="signature">(ids)</span><span class="type-signature"> &rarr; {Promise|Array.&lt;GraphModel>}</span></h4>
    

    



<div class="description">
    <p>Fetches multiple products by ID on the shop.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>ids</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array.&lt;String></span>


            
            </td>

            

            

            <td class="description last"><p>The ids of the products to fetch</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line70">line 70</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A promise resolving with a <code>GraphModel</code> of the product.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>
|

<span class="param-type">Array.&lt;GraphModel></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>const ids = ['Xk9lM2JkNzFmNzIQ4NTIY4ZDFi9DaGVja291dC9lM2JkN==', 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzc4NTc5ODkzODQ='];
client.product.fetchMultiple(ids).then((products) => {
  // Do something with the products
});</code></pre>



        
            

    

    
    <h4 class="name" id="fetchQuery"><span class="type-signature"></span>fetchQuery<span class="signature">(args<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise|Array.&lt;GraphModel>}</span></h4>
    

    



<div class="description">
    <p>Fetches all products on the shop that match the query.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>args</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>An object specifying the query data containing zero or more of:</p>
                <h6>Properties</h6>
                

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>first</code></td>
            

            <td class="type">
            
                
<span class="param-type">Int</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    20
                
                </td>
            

            <td class="description last"><p>The relay <code>first</code> param. This specifies page size.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sortKey</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    ID
                
                </td>
            

            <td class="description last"><p>The key to sort results by. Available values are
documented as <a href="https://help.shopify.com/api/storefront-api/reference/enum/productsortkeys">Product Sort Keys</a>.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>query</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>A query string. See full documentation <a href="https://help.shopify.com/api/storefront-api/reference/object/shop#products">here</a></p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>reverse</code></td>
            

            <td class="type">
            
                
<span class="param-type">Boolean</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last"><p>Whether or not to reverse the sort order of the results</p></td>
        </tr>

    
    </tbody>
</table>

            </td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line111">line 111</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A promise resolving with an array of <code>GraphModel</code>s of the products.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>
|

<span class="param-type">Array.&lt;GraphModel></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>client.product.fetchQuery({first: 20, sortKey: 'CREATED_AT', reverse: true}).then((products) => {
  // Do something with the first 10 products sorted by title in ascending order
});</code></pre>



        
            

    

    
    <h4 class="name" id="fetchRecommendations"><span class="type-signature"></span>fetchRecommendations<span class="signature">(productId)</span><span class="type-signature"> &rarr; {Promise|Array.&lt;GraphModel>}</span></h4>
    

    



<div class="description">
    <p>Find recommended products related to a given productId.
To learn more about how recommendations are generated, see https://shopify.dev/themes/product-merchandising/recommendations.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>productId</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>The id of the product to fetch.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product-resource.js.html">product-resource.js</a>, <a href="product-resource.js.html#line136">line 136</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>A promise resolving with an array of <code>GraphModel</code>s of the products.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>
|

<span class="param-type">Array.&lt;GraphModel></span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>const productId 'Xk9lM2JkNzFmNzIQ4NTIY4ZDFi9DaGVja291dC9lM2JkN==';
client.product.fetchProductRecommendations(productId).then((products) => {
  // Do something with the products
});</code></pre>



        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="ImageHelpers.html">ImageHelpers</a></li><li><a href="ProductHelpers.html">ProductHelpers</a></li></ul><h3>Classes</h3><ul><li><a href="CheckoutResource.html">CheckoutResource</a></li><li><a href="Client.html">Client</a></li><li><a href="CollectionResource.html">CollectionResource</a></li><li><a href="Config.html">Config</a></li><li><a href="ImageResource.html">ImageResource</a></li><li><a href="ProductResource.html">ProductResource</a></li><li><a href="ShopResource.html">ShopResource</a></li></ul><h3>Global</h3><ul><li><a href="global.html#normalizeCartMoneyFieldDecimalPlaces">normalizeCartMoneyFieldDecimalPlaces</a></li><li><a href="global.html#shouldReturnWithOneDecimalPlace">shouldReturnWithOneDecimalPlace</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Mar 12 2025 16:11:31 GMT-0400 (Eastern Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>